package com.david.config;

import feign.Logger;
import feign.RequestInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;

/**
 * @Description: FeignConfiguration
 * @Author: wangwei
 * @CreateDate: 2022/1/20 14:50
 */
@Configuration
public class FeignConfiguration {

//    @Bean("requestInterceptor")
//    public RequestInterceptor requestInterceptor(){
//        return template -> {
//            ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
//            HttpServletRequest request = attributes.getRequest();
//            String cookie = request.getHeader("Cookie");
//            template.header("Cookie",cookie);
//        };
//    }

    @Bean
    Logger.Level feignLoggerLeave(){
        return Logger.Level.FULL;
    }
}